package com.sec.android.app.myfiles.module.shortcut;

import android.content.Context;

import com.sec.android.app.myfiles.MyFilesTestRunner;
import com.sec.android.app.myfiles.mockclass.CursorMock;
import com.sec.android.app.myfiles.module.abstraction.FileRecord;
import com.sec.android.app.myfiles.shadow.android.ShadowContentResolver;

import junit.framework.Assert;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.RuntimeEnvironment;

/**
 * Created by jaebae on 2016-11-23.
 */

@RunWith(MyFilesTestRunner.class)
public class testShortcutUtils {
    Context mContext;

    @Before
    public void setUp() throws Exception {
        mContext = RuntimeEnvironment.application;
    }

    @After
    public void tearDown() throws Exception {
    }

    @Test
    public void testIsExistFromShortcut() {
        Assert.assertFalse(ShortcutUtils.isExistFromShortcut(null, FileRecord.createFileRecord(FileRecord.StorageType.Local, "/test/test.txt")));
        Assert.assertFalse(ShortcutUtils.isExistFromShortcut(mContext, null));

        ShadowContentResolver.setCursor(null);
        Assert.assertFalse(ShortcutUtils.isExistFromShortcut(mContext, FileRecord.createFileRecord(FileRecord.StorageType.Local, "/test/test.txt")));

        ShadowContentResolver.setCursor(CursorMock.createCursor(0));
        Assert.assertFalse(ShortcutUtils.isExistFromShortcut(mContext, FileRecord.createFileRecord(FileRecord.StorageType.Local, "/test/test.txt")));

        ShadowContentResolver.setCursor(CursorMock.createCursor(1));
        Assert.assertTrue(ShortcutUtils.isExistFromShortcut(mContext, FileRecord.createFileRecord(FileRecord.StorageType.Local, "/test/test.txt")));
    }
}
